package org.jeecg.modules.bus.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.constant.CommonConstant;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.TokenUtils;
import org.jeecg.config.ApiVersion;
import org.jeecg.config.ApiVersionConstant;
import org.jeecg.config.WebConfig;
import org.jeecg.modules.business.entity.BusParamXcxRoom;
import org.jeecg.modules.business.service.IBusParamXcxRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;

/**
 * 小程序客房服务
 */
@Api(tags="小程序客房服务")
@RestController
@RequestMapping("/mall-api/param-xcx-room")
@Slf4j
public class ParamXcxRoomController extends WebConfig {
   @Resource
   private IBusParamXcxRoomService busParamXcxRoomService;

    /**
     * 通过hotelId查询
     *
     * @param hotelId
     * @return
     */
    @ApiOperation(value="小程序客房服务设置-通过hotelId查询", notes="小程序客房服务设置-通过hotelId查询")
    @GetMapping(value = "/queryByHotelId")
    @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
    public Result<BusParamXcxRoom> queryByHotelId(@RequestParam(name="hotelId") String hotelId) {
        if (StringUtils.isBlank(hotelId)) {
            return Result.error("暂未入住酒店");
        }
        QueryWrapper<BusParamXcxRoom> queryWrapper = new QueryWrapper<BusParamXcxRoom>();
        queryWrapper.eq("hotel_id", hotelId);
        BusParamXcxRoom resultModel = busParamXcxRoomService.getOne(queryWrapper);
        return Result.OK(resultModel);
    }
}
